package com.component.api.model.param;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 描述：
 * 组件内置属性
 * @author xianggj
 * @Date 2021/11/25 13:54
 **/
@Data
@NoArgsConstructor
public class ComponentDefine implements Serializable {

    private String name;

    /**
     * 入参 前端传递过来的参数
     */
    private List<InParam> inParams;

    /**
     * 出参，转换后喂给算子的参数
     */
    private List<ParamPair> outParams;

    private List<Port> ports;

    public Map<String,ParamPair> outParamsMap() {
        if (outParams == null){
            return new HashMap<>();
        }
        return outParams.stream().collect(Collectors.toMap(ParamPair::getName, Function.identity()));
    }
}
